package com.example.demo.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

@Component
public class MyHandlerInterceptor implements HandlerInterceptor{

	/**
	 * 视图编译完成后，即将输出，一般用于处理异常
	 */
	@Override
	public void afterCompletion(HttpServletRequest req, HttpServletResponse resp, Object args, Exception e)
			throws Exception {
//		resp.getWriter().println("afterCompletion");
		
	}

	/**
	 * 目标方法执行之后，即将进入view也就是(jsp)
	 */
	@Override
	public void postHandle(HttpServletRequest req, HttpServletResponse resp, Object args, ModelAndView mv)
			throws Exception {
//		resp.getWriter().println("postHandle");
		
	}

	/**
	 * 目标controller执行之前
	 */
	@Override
	public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object args) throws Exception {
//		resp.getWriter().println("preHandle");
		return true;
	}

}
